package com.design.softwaredesign.controller;

import com.design.softwaredesign.service.BackCampusService;
import com.design.softwaredesign.service.BackDonationService;
import com.design.softwaredesign.vo.DataVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.xml.crypto.Data;

/**
 * @author :WaiterXiaoYY
 * @description: TODO
 * @data :2020/11/15 9:10
 */
@Api(description = "管理员后台控制层-用户捐赠管理")
@RestController
@RequestMapping("/web/admin")
public class BackDonationController {
    @Autowired
    private BackDonationService backDonationService;

    @ApiOperation(value = "获取未送达的捐赠物品")
    @GetMapping("/getdonationnoarrival")
    public DataVo getDonationNoArrival(Integer pageNum, Integer pageSize, String query) {
        DataVo dataVo = new DataVo();
        dataVo = backDonationService.getDonationNoArrival(pageNum, pageSize, query);
        return dataVo;
    }

    @ApiOperation(value = "获取已送达的捐赠物品")
    @GetMapping("/getdonationarrival")
    public DataVo getDonationArrival(Integer pageNum, Integer pageSize, String query) {
        DataVo dataVo = new DataVo();
        dataVo = backDonationService.getDonationArrival(pageNum, pageSize, query);
        return dataVo;
    }

    @ApiOperation(value = "修改捐赠的状态")
    @PostMapping("/changedonationstate/{donationId}/{num}")
    public DataVo changeDonationState(@PathVariable String donationId, @PathVariable Integer num) {
        DataVo dataVo = new DataVo();
        dataVo = backDonationService.changeDonationState(donationId, num);
        return dataVo;
    }

    @GetMapping("/getdonationtimestamp/{donationId}")
    @ApiOperation(value = "获取时间线")
    public DataVo getDonationTimestamp(@PathVariable("donationId") String donationId) {
        return  backDonationService.getDonationTimestamp(donationId);
    }

    @DeleteMapping("/deletedonation/{donationId}")
    @ApiOperation(value = "删除捐赠信息")
    public DataVo deleteDonationById(@PathVariable("donationId") String donationId) {
        return  backDonationService.deleteDonationById(donationId);
    }
}
